import { useSelector, useDispatch } from 'umi';
import { Button } from 'antd';

const Index = () => {
  const name = useSelector((state: any) => {
    console.log(state);
    return state.abc.name;
  });
  const count = useSelector((state: any) => state.abc.count);

  const dispatch = useDispatch();

  return (
    <>
      <h2>dva页面</h2>
      <p>name: {name}</p>
      <Button
        type="primary"
        onClick={() => dispatch({ type: 'abc/changeName', payload: 'lisi' })}
      >
        btn
      </Button>

      <hr />

      <Button
        onClick={() => dispatch({ type: 'abc/decrementAsync', payload: 2 })}
      >
        --
      </Button>
      <p>count: {count}</p>
      <Button onClick={() => dispatch({ type: 'abc/increment' })}>++</Button>
    </>
  );
};

export default Index;
